#include <iostream>
#include <string>
using namespace std;


const int N = 1e5 + 10;
int dp[N];
int arr[N];

int main()
{
	int crr[10];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> arr[i];

	int ret = -100;
	for (int i = 1; i <= n; i++)
	{
		dp[i] = max(dp[i - 1], 0) + arr[i];
		ret = max(ret, dp[i]);
	}
	cout << ret << endl;
	return 0;
}